﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="pragma" content="no-cache" />
    <meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
    <meta http-equiv="expires" content="0" />
    <title>FaceCat</title>
</head>
<body>
    <canvas id="mycanvas" width="1000" height="700" style="position: fixed; left: 0px; top: 0px;"/>
    <script type="text/javascript" src="facecat.js"></script>
    <script type="text/javascript">
        let canvas = document.getElementById("mycanvas"); //绘图区域
        let context = canvas.getContext("2d"); //绘图上下文
        canvas.width = window.innerWidth;
        canvas.height = window.innerHeight;
        let gPaint = new FCPaint(); //绘图对象
        gPaint.canvas = canvas;
        scaleCanvas(gPaint);
        //判断是否移动端
        gPaint.isMobile = isMobileMode();
        if (gPaint.isMobile) {
            gPaint.scaleFactorX = 2.5;
            gPaint.scaleFactorY = 2.5;
        }
        //判断主题色
        gPaint.defaultUIStyle = "light";
        addDefaultEvent(canvas, gPaint);

        /*
         * 重置大小
         */
        let resizeAll = function () {
            try {
                canvas.width = document.documentElement.clientWidth;
                canvas.height = document.documentElement.clientHeight;
                scaleCanvas(gPaint);
                updateViewDefault(gPaint.views);
            } catch (err) {
                //alert(err);
            }
            invalidate(gPaint);
        };

        /*
        * 监听大小改变
        */
        window.onresize = function () {
            resizeAll();
        };

        /*
        * 旋转监听
        */
        window.onorientationchange = function () {
            resizeAll();
        };

        //解析加载XML
        let xml = `<?xml version="1.0" encoding="utf-8"?>
        <html xmlns="facecat">
          <head>
          </head>
          <body>
            <div dock="fill" type="tab" selectedindex="0">
              <div name="TabPage" text="可视化生成" type="tabpage">
                <div type="layout" name="LayoutDiv" text="LayoutDiv" location="30,30" size="265,99" showhscrollbar="True" allowdragscroll="true" allowpreviewsevent="true">
                  <input type="button" name="Button" text="Button" location="27,26" size="100,20" />
                  <input type="button" name="Button2" text="Button2" location="27,26" size="100,20" />
                  <input type="button" name="Button3" text="Button3" location="27,26" size="100,20" />
                  <input type="button" name="Button4" text="Button4" location="27,26" size="100,20" />
                  <input type="button" name="Button5" text="Button5" location="27,26" size="100,20" />
                  <input type="button" name="Button6" text="Button6" location="27,26" size="100,20" />
                </div>
                <div type="layout" name="LayoutDiv2" text="LayoutDiv2" location="71,210" size="135,234" layoutstyle="TopToBottom" showvscrollbar="True" allowdragscroll="true" allowpreviewsevent="true">
                  <input type="button" name="Button7" text="Button7" location="27,26" size="100,100" />
                  <input type="button" name="Button8" text="Button8" location="27,26" size="100,100" />
                  <input type="button" name="Button9" text="Button9" location="27,26" size="100,100" />
                  <input type="button" name="Button10" text="Button10" location="27,26" size="100,100" />
                  <input type="button" name="Button11" text="Button11" location="27,26" size="100,100" />
                  <input type="button" name="Button12" text="Button12" location="27,26" size="100,100" />
                </div>
              </div>
              <div name="TabPage2" text="代码创建" type="tabpage" />
            </div>
          </body>
        </html>
        `;
        renderFaceCat(gPaint, xml);
        let tabPage = findViewByName("TabPage2", gPaint.views);
        let layoutDiv = new FCLayoutDiv();
        layoutDiv.location = new FCPoint(50, 50);
        layoutDiv.size = new FCSize(250, 100);
        layoutDiv.showHScrollBar = true;
        addViewToParent(layoutDiv, tabPage);
        for (let i = 0; i < 10; i++) {
            let button = new FCButton();
            button.location = new FCPoint(0, 0);
            button.size = new FCSize(100, 40);
            button.backColor = "rgb(255,255,255)";
            button.textColor = "rgb(0,0,0)";
            button.borderColor = "rgb(150,150,150)";
            addViewToParent(button, layoutDiv);
            button.text = "Button";
        }
        resetLayoutDiv(layoutDiv);
    </script>
</body>
</html>
